feat: adds docs command with optional search flag#352
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #352 +/- ##
==========================================
+ Coverage 64.95% 65.08% +0.13%
==========================================
Files 214 215 +1
Lines 18118 18179 +61
==========================================
+ Hits 11768 11832 +64
+ Misses 5254 5253 -1
+ Partials 1096 1094 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
docs command with optional search paramdocs command with optional search flag
zimeg
left a comment
There was a problem hiding this comment.
☕️ Leaving a few notes from the coffee shop-
cmd/docs/docs.go
Outdated
|
|
||
| clients.Browser().OpenURL(docsURL) | ||
|
|
||
| // Add trace for analytics |
There was a problem hiding this comment.
🧪 note: We use these traces for testing certain paths are reached in our E2E tests:
$ SLACK_TEST_TRACE=1 slack docs
It might be nice to update or remove this comment to avoid ongoing confusion toward this!
docs command with optional search flagdocs command with optional search flag
|
@zimeg thank you kindly for the coffee shop review. i've updated per your suggestion (while drinking coffee but at home alas) |
zimeg
left a comment
There was a problem hiding this comment.
@lukegalbraithrussell I appreciate the fast changes! Coffee finds me good too in the office ☕ ✨
I'm leaving a few more comments about the standalone search patterns. This is a smooth path to a familiar search experience that I'd like to support, but feel free to hold off on those changes if it's not envisioned 👁️🗨️
cmd/docs/docs_test.go
Outdated
| "handles empty search query as homepage": { | ||
| CmdArgs: []string{"--search", ""}, | ||
| ExpectedAsserts: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock) { | ||
| expectedURL := "https://docs.slack.dev" | ||
| cm.Browser.AssertCalled(t, "OpenURL", expectedURL) | ||
| cm.IO.AssertCalled(t, "PrintTrace", mock.Anything, slacktrace.DocsSuccess, mock.Anything) | ||
| }, | ||
| ExpectedOutputs: []string{ | ||
| "Docs Open", | ||
| "https://docs.slack.dev", | ||
| }, | ||
| }, |
There was a problem hiding this comment.
🧪 issue: This case is a bit misleading to me! I tried using the search flag without an argument to find this error:
$ slack docs --search
Check /Users/eden.zimbelman/.slack/logs/slack-debug-20260226.log for error logs
flag needs an argument: --search
should this instead open
docs.slack.dev/search?
I do think this would be ideal - perhaps "https://docs.slack.dev/search/" complete - if possible, without an argument?
cmd/docs/docs.go
Outdated
| }, | ||
| } | ||
|
|
||
| cmd.Flags().StringVar(&searchFlag, "search", "", "search query for Slack docs") |
There was a problem hiding this comment.
🪬 suggestion: Related to the "required" search value if the "--search" flag is provided - I wonder if we can change this to be a "boolean" value?
This might allow this command to accept 1 argument instead of 0 for sake of being the search query? We might then search if that flag is provided or if an argument is used:
$ slack docs --search
$ slack docs "Block Kit"
$ slack docs --search "Block Kit"
We ought not need to document the second case IMHO since it's identical to the third, and I don't think such approach limits future changes. Not a blocker here but the examples might need updating before merge!
zimeg
left a comment
There was a problem hiding this comment.
💡 @lukegalbraithrussell This is getting so good! I'm leaving one more comment of edge cases found, but I'm so optimistic!
| var sectionText string | ||
|
|
||
| // Validate: if there are arguments, --search flag must be used | ||
| if len(args) > 0 && !cmd.Flags().Changed("search") { |
There was a problem hiding this comment.
🪬 suggestion: We might still want to keep a max arguments setting for this command, but set to 1. It can be confusing otherwise to find:
(.venv) $ lack docs --search one two
📚 Docs Search
https://docs.slack.dev/search/?q=one
Although we can also update this section with "variadic" arguments to join the arguments together - IMHO this might be ideal if not so complicated 👻
There was a problem hiding this comment.
it now joins the arguments together!
slack docs --search one two three now returns the search query of "one two three"
zimeg
left a comment
There was a problem hiding this comment.
@lukegalbraithrussell This is so awesome alongside the fast load times 🤩 ✨
Thanks so much for all of the iteration toward this. It's in a solid place to ship I'm finding - LGTM 🚢 💨
| }, | ||
| } | ||
|
|
||
| cmd.Flags().BoolVar(&searchMode, "search", false, "open Slack docs search page or search with query") |
There was a problem hiding this comment.
| cmd.Flags().BoolVar(&searchMode, "search", false, "open Slack docs search page or search with query") | |
| cmd.Flags().Bool("search", false, "open Slack docs search page or search with query") |
🪓 suggestion(non-blocking): We can perhaps remove searchMode as a variable with the lookup patterns that follow. IMHO it's a nice change that we could bring to other commands...
| var searchMode bool | ||
|
|
There was a problem hiding this comment.
| var searchMode bool |
🪓 suggesetion(non-blocking): Related to the earlier comment!
srtaalej
left a comment
There was a problem hiding this comment.
lgtm!! we can follow up on edengod's suggestions - it'd be great to land this command in the next release! 🚀
Changelog
The
slack docscommand opens the slack docs site; its--searchflag opens the slack docs search page with the provided search query.Summary
This PR adds a
docscommand.slack docsdocs.slack.devslack docs --searchdocs.slack.dev/searchslack docs --search something cooldocs.slack.dev/search/?q=something+coolslack docs something--searchflag?This doesn't take advantage of the charm experiment. Next steps though!!!
Requirements